Add gpsdrive, courtesy Alan Curry.
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Tue, 3 Dec 2002 22:48:36 +0000 (22:48 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Tue, 3 Dec 2002 22:48:36 +0000 (22:48 +0000)
gpsbabel/Makefile
gpsbabel/README
gpsbabel/gpsdrive.c [new file with mode: 0644]
gpsbabel/reference/gpsdrive.txt [new file with mode: 0644]
gpsbabel/testo
gpsbabel/vecs.c

index 30bf69ff523a31b796f31128066a30981a86efcc..421be7e71b1602416c128599d1bfd779c7a92dbe 100644 (file)
@@ -2,7 +2,7 @@ CFLAGS=-g -Icoldsync
 
 FMTS=magproto.o gpx.o geo.o gpsman.o mapsend.o mapsource.o \
        gpsutil.o tiger.o pcx.o csv.o cetus.o gpspilot.o magnav.o \
-       psp.o mxf.o holux.o garmin.o ozi.o tmpro.o dna.o tpg.o
+       psp.o mxf.o holux.o garmin.o ozi.o tmpro.o dna.o tpg.o gpsdrive.o
 
 JEEPS=jeeps/gpsapp.o jeeps/gpscom.o jeeps/gpsfmt.o jeeps/gpsinput.o \
        jeeps/gpsmath.o jeeps/gpsmem.o  \
@@ -48,6 +48,7 @@ garmin.o: garmin.c defs.h queue.h jeeps/gps.h jeeps/gpsport.h \
   jeeps/gpsmath.h jeeps/gpsnmea.h jeeps/gpsmem.h jeeps/gpsrqst.h \
   jeeps/gpsinput.h jeeps/gpsproj.h jeeps/gpsnmeafmt.h jeeps/gpsnmeaget.h
 geo.o: geo.c defs.h queue.h
+gpsdrive.o: gpsdrive.c defs.h queue.h csv_util.h
 gpsman.o: gpsman.c defs.h queue.h
 gpspilot.o: gpspilot.c defs.h queue.h coldsync/palm.h coldsync/pdb.h
 gpsutil.o: gpsutil.c defs.h queue.h magellan.h
index d254cb58ea0e1bfaea87c26eab7a64c6864a300b..a6588674aee9e8275884dbefbf2ef04707e16148 100644 (file)
@@ -223,6 +223,12 @@ THE FORMATS
         data, your output file won't either.
         Colour of waypoint icons defaults to red.
 
+    GPSDRIVE
+  
+        GpsDrive way.txt file format. A space seperated format file. Tested
+        against GpsDrive v 1.30 found @ http://www.kraftvoll.at/software.
+        Contributed by Alan Curry.
+
 
 COMMON USAGE
 
diff --git a/gpsbabel/gpsdrive.c b/gpsbabel/gpsdrive.c
new file mode 100644 (file)
index 0000000..ef9fe2b
--- /dev/null
@@ -0,0 +1,176 @@
+/*
+  Space separated value files for GpsDrive waypoints.
+
+  GpsDrive can be found @ http://www.kraftvoll.at/software
+       
+  Format: 
+
+  waypoint latitude longitude 
+   
+  12/01/02 - hacked cvs.c by alan curry
+  
+    Copyright (C) 2002 Robert Lipe, robertlipe@usa.net
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
+
+*/
+
+#include "defs.h"
+#include "csv_util.h"
+#include <ctype.h>
+
+static FILE *file_in;
+static FILE *file_out;
+
+#define MYNAME "GPSDRIVE"
+
+static void
+rd_init(const char *fname, const char *args)
+{
+       file_in = fopen(fname, "r");
+       if (file_in == NULL) {
+               fatal(MYNAME ": Cannot open %s for reading\n", fname);
+       }
+}
+
+static void
+rd_deinit(void)
+{
+       fclose(file_in);
+}
+
+static void
+wr_init(const char *fname, const char *args)
+{
+       file_out = fopen(fname, "w");
+       if (file_out == NULL) {
+               fatal(MYNAME ": Cannot open %s for writing\n", fname);
+       }
+}
+
+
+static void
+wr_deinit(void)
+{
+       fclose(file_out);
+}
+
+static void
+data_read(void)
+{
+       char buff[1024];
+       char *s;
+       int i;
+       waypoint *wpt_tmp;
+       int linecount = 0;
+
+       do {
+               linecount++;
+               memset(buff, '\0', sizeof(buff));
+               fgets(buff, sizeof(buff), file_in);
+                 
+               if (strlen(buff)) {
+
+                   wpt_tmp = xcalloc(sizeof(*wpt_tmp), 1);
+                   s = buff;
+
+                   /* data delimited by spaces, not enclosed */
+                   s = csv_lineparse(s, " ", "", linecount);
+
+               i = 0;
+
+               while (s) {
+
+                       switch (i) {
+                       case 0:
+                               wpt_tmp->description = csv_stringtrim(s, " ");
+                               break;
+                       case 1:
+                               wpt_tmp->position.latitude.degrees = atof(s);
+                               break;
+                       case 2:
+                               wpt_tmp->position.longitude.degrees = atof(s);
+                       break;
+                       default:
+                           fprintf (stderr, "%s: Warning: unmapped data fields on line %d.\n", 
+                               MYNAME, linecount);
+                           break;
+                       }
+                       i++;
+
+                       s = csv_lineparse(NULL, " ", "", linecount);
+               }
+           
+               wpt_tmp->creation_time = time(NULL);
+               
+               /* We'll make up our own shortname. */
+               if (wpt_tmp->description) {
+                       wpt_tmp->shortname = mkshort(wpt_tmp->description);
+                       waypt_add(wpt_tmp);
+               }
+
+       } else {
+               /* empty line */
+       }
+
+    } while (!feof(file_in));
+}
+
+static void
+gpsdrive_waypt_pr(const waypoint *wpt)
+{
+       double lon,lat;
+       char * shortname = NULL;
+
+       lon = wpt->position.longitude.degrees;
+       lat = wpt->position.latitude.degrees;
+
+       if ( wpt->shortname )
+               shortname = csv_stringclean(wpt->shortname, ",\"");
+               
+       if (( shortname == NULL ) && wpt->description )
+               shortname = csv_stringclean(wpt->description, ",\"");   
+
+       if (( shortname == NULL ) && wpt->notes )
+           shortname = csv_stringclean(wpt->notes, ",\"");
+
+       if ( shortname )
+               shortname = mkshort(shortname);
+
+       fprintf(file_out, "%s %08.5f %08.5f\n",
+               shortname,
+               lat,
+               lon);
+               
+       if (shortname)
+               free (shortname);
+
+}
+
+static void
+data_write(void)
+{
+       waypt_disp_all(gpsdrive_waypt_pr);
+}
+
+ff_vecs_t gpsdrive_vecs = {
+       rd_init,
+       wr_init,
+       rd_deinit,
+       wr_deinit,
+       data_read,
+       data_write,
+};
+
diff --git a/gpsbabel/reference/gpsdrive.txt b/gpsbabel/reference/gpsdrive.txt
new file mode 100644 (file)
index 0000000..65e18b8
--- /dev/null
@@ -0,0 +1,9 @@
+GCEBB 35.97203 -87.13470
+GC1A37 36.09068 -86.67955
+GC1C2B 35.99627 -86.62012
+GC25A9 36.03848 -86.64862
+GC2723 36.11218 -86.74177
+GC2B71 36.06408 -86.79052
+GC309F 36.08777 -86.80973
+GC317A 36.05750 -86.89200
+GC317D 36.08280 -86.86728
index 083a170f7046b66e3a1409ee6050683b96caf3f4..57145ed893c5c807c64b4abedd2715c78b7ed8f0 100755 (executable)
@@ -158,3 +158,11 @@ ${PNAME} -i cetus -f ${TMPDIR}/cetus.pdb -o gpsutil -F ${TMPDIR}/cetus.gpu
 ${PNAME} -i cetus -f reference/cetus.pdb -o gpsutil -F ${TMPDIR}/cetust.gpu
 diff ${TMPDIR}/cetust.gpu ${TMPDIR}/cetus.gpu
 diff reference/cetus.gpu ${TMPDIR}/cetus.gpu
+
+# GpsDrive
+rm -f ${TMPDIR}/gpsdrive.txt
+${PNAME} -i geo -f geocaching.loc -o gpsdrive -F ${TMPDIR}/gpsdrive.txt
+diff ${TMPDIR}/gpsdrive.txt reference
+${PNAME} -i gpsdrive -f reference/gpsdrive.txt -o gpsdrive -F ${TMPDIR}/gpsdrive2.txt
+diff ${TMPDIR}/gpsdrive2.txt reference/gpsdrive.txt
+
index 802bfe6f104bce929313e455d0c9748dc9733607..e2ff3452ec6408ffb9c36b1ef91a7cdd9525e812 100644 (file)
@@ -50,6 +50,7 @@ extern ff_vecs_t dna_vecs;
 extern ff_vecs_t magnav_vec;
 extern ff_vecs_t xmap_vecs;
 extern ff_vecs_t tmpro_vecs;
+extern ff_vecs_t gpsdrive_vecs;
 
 static
 vecs_t vec_list[] = {
@@ -163,6 +164,11 @@ vecs_t vec_list[] = {
                "tmpro",
                "TopoMapPro Places File"
        },
+       {
+               &gpsdrive_vecs,
+               "gpsdrive",
+               "GpsDrive Format"
+       },
 
         {
                NULL,